<html>
<head><meta charset="utf-8"><title>NOP intrinsic · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/NOP.20intrinsic.html">NOP intrinsic</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="152592049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/NOP%20intrinsic/near/152592049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/NOP.20intrinsic.html#152592049">(Dec 27 2018 at 08:43)</a>:</h4>
<p>I am trying to write an intrinsic <code>panic_if_uninhabited</code> that compiles statically to a panic or a NOP depending on the type argument -- something like a generalization of the panic-on-uninhabited we <a href="https://github.com/rust-lang/rust/pull/54667/files" target="_blank" title="https://github.com/rust-lang/rust/pull/54667/files">have for <code>mem::{uninhabited,zeroed}</code></a>. Based on that existing code, getting the panic path was easy, but I have no idea how to make a NOP path. I have a WIP commit at <a href="https://github.com/RalfJung/rust/commit/80471dd8e2c71b5c47b471ce2121f20306d8afe2" target="_blank" title="https://github.com/RalfJung/rust/commit/80471dd8e2c71b5c47b471ce2121f20306d8afe2">https://github.com/RalfJung/rust/commit/80471dd8e2c71b5c47b471ce2121f20306d8afe2</a>. Any suggestions? Cc <span class="user-mention" data-user-id="119009">@eddyb</span></p>



<a name="152596776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/NOP%20intrinsic/near/152596776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/NOP.20intrinsic.html#152596776">(Dec 27 2018 at 11:10)</a>:</h4>
<p>Well... a NOP is just to go to the next block, so I'd presume you'd do the same thing as a goto does: <a href="https://github.com/RalfJung/rust/blob/80471dd8e2c71b5c47b471ce2121f20306d8afe2/src/librustc_codegen_ssa/mir/block.rs#L193" target="_blank" title="https://github.com/RalfJung/rust/blob/80471dd8e2c71b5c47b471ce2121f20306d8afe2/src/librustc_codegen_ssa/mir/block.rs#L193">https://github.com/RalfJung/rust/blob/80471dd8e2c71b5c47b471ce2121f20306d8afe2/src/librustc_codegen_ssa/mir/block.rs#L193</a></p>



<a name="152596836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/NOP%20intrinsic/near/152596836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/NOP.20intrinsic.html#152596836">(Dec 27 2018 at 11:12)</a>:</h4>
<p>where <code>target</code> is replaced with <code>destination.as_ref().map(|(_, bb)| bb)</code> (possibly with an <code>unwrap</code> afterwards)</p>



<a name="152596970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/NOP%20intrinsic/near/152596970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/NOP.20intrinsic.html#152596970">(Dec 27 2018 at 11:16)</a>:</h4>
<p>hm actually my panic-case is also wrong because it determines the type to check by looking at the return type. I need the first type of the substitution instead.</p>



<a name="152598599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/NOP%20intrinsic/near/152598599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/NOP.20intrinsic.html#152598599">(Dec 27 2018 at 12:06)</a>:</h4>
<p>that seems to work, superficially: <a href="https://github.com/rust-lang/rust/pull/57145" target="_blank" title="https://github.com/rust-lang/rust/pull/57145">https://github.com/rust-lang/rust/pull/57145</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>